//package com.yunhe.option.controller.data;
//
//import com.yunhe.option.domain.data.SeasonPrice;
//import com.yunhe.option.domain.data.SeasonPriceDetail;
//import com.yunhe.common.exception.ArgumentErrorException;
//import com.yunhe.common.exception.ObjectNotFoundException;
//import com.yunhe.common.exception.UniqueConstraintsException;
//import com.yunhe.common.model.DomainList;
//import com.yunhe.common.model.ResultObject;
//import com.yunhe.option.service.data.SeasonPriceService;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiImplicitParam;
//import io.swagger.annotations.ApiImplicitParams;
//import io.swagger.annotations.ApiOperation;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.http.HttpStatus;
//import org.springframework.http.ResponseEntity;
//import org.springframework.web.bind.annotation.*;
//
//import java.util.List;
//import java.util.Optional;
//
//
//@Api(value = "seasonPrice", description = "季节电价维护", tags = {"Data_SeasonPrice"})
//@RestController
//@RequestMapping("/prices/cost")
//public class SeasonPriceController {
//    @Autowired
//    private SeasonPriceService seasonPriceService;
//
//    @ApiOperation("新增季节电价")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "systemId", value = "系统ID", required = true, dataType = "long", paramType = "path"),
//            @ApiImplicitParam(name = "costPriceId", value = "用电电价ID", required = true, dataType = "long", paramType = "path")
//    })
//    @RequestMapping(value = "/{costPriceId}/season", method = RequestMethod.POST)
//    public ResponseEntity<ResultObject> post(@PathVariable("costPriceId") Long costPriceId,
//                                             @RequestBody SeasonPrice seasonPrice)
//        throws ArgumentErrorException, UniqueConstraintsException, ObjectNotFoundException{
//        SeasonPrice newSeasonPrice = seasonPriceService.create(seasonPrice, costPriceId);
//        return new ResponseEntity<>(new ResultObject(newSeasonPrice), HttpStatus.OK);
//    }
//
//    @ApiOperation("批量新增季节电价")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "systemId", value = "系统ID", required = true, dataType = "long", paramType = "path"),
//            @ApiImplicitParam(name = "costPriceId", value = "用电电价ID", required = true, dataType = "long", paramType = "path")
//    })
//    @RequestMapping(value = "/{costPriceId}/season/batch", method = RequestMethod.POST)
//    public ResponseEntity<ResultObject> batchPost(@PathVariable("costPriceId") Long costPriceId,
//                                                  @RequestBody DomainList<SeasonPrice> seasonPrices)
//            throws ArgumentErrorException, UniqueConstraintsException, ObjectNotFoundException{
//        Iterable<SeasonPrice> newSeasonPrice = seasonPriceService.create(seasonPrices.getList(), costPriceId);
//        return new ResponseEntity<>(new ResultObject(newSeasonPrice), HttpStatus.OK);
//    }
//
//    @ApiOperation("根据ID删除季节电价")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "systemId", value = "系统ID", required = true, dataType = "long", paramType = "path"),
//            @ApiImplicitParam(name = "id", value = "季节电价ID", required = true, dataType = "long", paramType = "path")
//    })
//    @RequestMapping(value = "/season/{id}", method = RequestMethod.DELETE)
//    public ResponseEntity<ResultObject> delete(@PathVariable("id") Long id)
//            throws ArgumentErrorException{
//        seasonPriceService.delete(id);
//        return new ResponseEntity<>(new ResultObject(null), HttpStatus.OK);
//    }
//
////    @ApiOperation("批量删除季节电价")
////    @ApiImplicitParam(name = "systemId", value = "系统ID", required = true, dataType = "long", paramType = "path")
////    @RequestMapping(value = "/season/batch", method = RequestMethod.DELETE)
////    public ResponseEntity<ResultObject> delete(@RequestBody DomainList<SeasonPrice> seasonPrices)
////            throws ArgumentErrorException{
////        seasonPriceService.delete(seasonPrices.getList());
////        return new ResponseEntity<>(new ResultObject(null), HttpStatus.OK);
////    }
//
//    @ApiOperation("更新季节电价（全部字段）")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "systemId", value = "系统ID", required = true, dataType = "long", paramType = "path"),
//            @ApiImplicitParam(name = "id", value = "季节电价ID", required = true, dataType = "long", paramType = "path")
//    })
//    @RequestMapping(value = "/season/{id}", method =  RequestMethod.PUT)
//    public ResponseEntity<ResultObject> put(@PathVariable("id") Long id,
//                                            @RequestBody SeasonPrice seasonPrice)
//            throws ArgumentErrorException, UniqueConstraintsException, ObjectNotFoundException{
//        seasonPrice.setId(id);
//        SeasonPrice newSeasonPrice = seasonPriceService.update(seasonPrice);
//        return new ResponseEntity<>(new ResultObject(newSeasonPrice), HttpStatus.OK);
//    }
//
//    @ApiOperation("更新季节电价（更新指定字段）")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "id", value = "季节电价ID", required = true, dataType = "long", paramType = "path"),
//            @ApiImplicitParam(name = "title", value = "地区标题", dataType = "string", paramType = "query"),
//            @ApiImplicitParam(name = "runMonth", value = "适用月份", dataType = "string", paramType = "query"),
//            @ApiImplicitParam(name = "priceRates", value = "电价费率", dataType = "string", paramType = "query"),
//            @ApiImplicitParam(name = "seasonPriceDetails", value = "季节电价详情", dataType = "List<SeasonPriceDetail>", paramType = "query"),
//    })
//    @RequestMapping(value = "/season/{id}", method =  RequestMethod.PATCH)
//    public ResponseEntity<ResultObject> patch(@PathVariable("id") Long id,
//                                              @RequestParam("title") Optional<String> title,
//                                              @RequestParam("runMonth") Optional<String> runMonth,
//                                              @RequestParam("priceRates") Optional<List<Long>> priceRates,
//                                              @RequestParam("seasonPriceDetails") Optional<List<SeasonPriceDetail>> details)
//            throws ArgumentErrorException, UniqueConstraintsException, ObjectNotFoundException{
//        SeasonPrice newSeasonPrice = seasonPriceService.update(id, title.orElse(null),
//                runMonth.orElse(null), priceRates.orElse(null), details.orElse(null));
//        return new ResponseEntity<>(new ResultObject(newSeasonPrice), HttpStatus.OK);
//    }
//
//    @ApiOperation("根据条件获得季节电价列表")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "costPriceId", value = "用电电价ID", dataType = "long", paramType = "query"),
//    })
//    @RequestMapping(value = "/season", method = RequestMethod.GET)
//    public ResponseEntity<ResultObject> search(@RequestParam("costPriceId") Optional<Long> costPriceId)
//            throws ArgumentErrorException, UniqueConstraintsException, ObjectNotFoundException{
//        List<SeasonPrice> newSeasonPrice = seasonPriceService.search(costPriceId.orElse(null));
//        return new ResponseEntity<>(new ResultObject(newSeasonPrice), HttpStatus.OK);
//    }
//}
